import time
from multiprocessing import Process
def foo(i):
    time.sleep(1)
    print('say hi', i)
    time.sleep(1)
if __name__ == '__main__':
    p_list=[]
    for i in range(10):
        p = Process(target=foo, args=(i,))
        p.daemon=True  # 默认是False,即主程序停止之后,进程会继续执行
        p_list.append(p)
    for p in p_list:
        p.start()
    for p in p_list:
        p.join()  # 主程序阻塞,直到所有进程执行完毕
    print('main process end')